package com.doit.day05

import java.io.{FileOutputStream, ObjectOutputStream}

object _06_样例类 {
  def main(args: Array[String]): Unit = {
    val a: Tiger = new Tiger(1, "a")
    val b: Tiger = new Tiger(1, "a")
    println(a == b )
    println(a)
    println(b)
    println(a.hashCode())
    println(b.hashCode())
    val a1: Tiger1 = Tiger1(1, "a")
    val a2: Tiger1 = Tiger1(1, "a")
    println(a1 == a2)//非常有意义   我先取比较类型
    println(a1)
    println(a2)
    val stream: ObjectOutputStream = new ObjectOutputStream(new FileOutputStream("d://abcd.txt"))
    stream.writeObject(a1)
    println(a1.hashCode())
    println(a2.hashCode())
  }
}

class Tiger(val id:Int,val name:String)

/**
 * 样例类
 * 1.实现了序列化接口
 * 2.重写了toString  hashcode  equals 方法
 * 3.还给我们实现了伴生类和伴生对象 并且写了 apply方法和unapply方法
 */
case class Tiger1(id:Int,name:String)